﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using myTwitter.BO;
using System.Web;
using System.Windows;

namespace myTwitter.Commands
{
    public class SearchTrendCmd : ICommand
    {
        private TrendTopic _trendTopic;

        public SearchTrendCmd(TrendTopic trendTopic)
        {
            _trendTopic = trendTopic;
        }

        #region ICommand Members

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            string topic = _trendTopic.Url.Replace("http://search.twitter.com/search?q=", string.Empty);
            GlobalController.Instances.ITwitterProvider.Search(topic);
            GlobalController.Views.Navigator._searchTab.Visibility = Visibility.Visible;
            GlobalController.Views.Navigator._tabControl.SelectedItem = GlobalController.Views.Navigator._searchTab;
        }

        #endregion
    }
}
